package com.dayuanit.dy17.atm.atmbackoffice.config;

import com.dayuanit.dy17.atm.atmbackoffice.service.impl.PowerServiceImpl;
import com.dayuanit.dy17.atm.atmbackoffice.service.impl.UserServiceImpl;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * 这是容器级的生命周期接口，是针对每一个bean对象的。
 */
@Component
public class BoBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof PowerServiceImpl) {
            System.out.println("--------------postProcess BeforeInitialization-------------- beanName=" + beanName);
        }

        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof PowerServiceImpl) {
            System.out.println("--------------postProcess AfterInitialization-------------- beanName=" + beanName);
        }

        return bean;
    }
}
